package com.briup.jz.web.controller;

import java.util.List;

import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.jz.bean.Platform;
import com.briup.jz.service.PlatformService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Api(description="platform(平台账户信息)相关接口")
@Validated
@RestController
@RequestMapping("/platform")
public class PlatformController{ 
	@Autowired
	private PlatformService platformService;
	
	@ApiOperation(value = "查询所有账户分类")
    @GetMapping("query")
    public Message query(Long id,String bankCard){
        List<Platform> list = platformService.query(id,bankCard);
        return MessageUtil.success(list);
    }
	
	@ApiOperation(value = "通过id删除")
    @GetMapping("deleteById")
    @ApiImplicitParams({
        @ApiImplicitParam(name="id",value = "主键",paramType = "query"),
    })
    public Message deleteById(@NotNull Long id){
		platformService.deleteById(id);
        return MessageUtil.success("删除成功");
    }

    @ApiOperation(value = "保存或更新地址分类信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name="id",value = "主键",paramType = "query",required = true),
            @ApiImplicitParam(name="balance",value = "收支情况",paramType = "query"),
            @ApiImplicitParam(name="bankCard",value = "卡号",paramType = "query"),
            
            
    })
    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(Platform platform){
    	platformService.saveOrUpdate(platform);
        return MessageUtil.success("更新成功");
    }

}
